%{

# define yylval studentslval

# include <string.h>
# include "parser.h"
# include "st.tab.h"

extern YYSTYPE yylval;

char * stripString (char *txt) {
	int i;
	char *str = (char *) malloc(sizeof(char)*strlen(txt));
	for (i=1;i<strlen(txt)-1;i++)
		str[i-1] = txt[i];
	str[i-1]='\0';
	return str;
}

%}

virgula		([0-9]*"."[0-9]+)
string		\'[^\']*\'
numero		[0-9]+
nomelb		[nN][oO][mM][eE]
numerolb	[nN][uUúÚ][mM][eE][rR][oO]
medialb		[Mm][eEÉé][dD][iI][aA]
esclb		[Ee][sS][cC][oO][lL][hH][aA][sS]
normallb	[Nn][oO][rR][mM][aA][lL]
prolb		[pP][rR][oO][fF][iI][sS][sS][iI][oO][nN][aA][lL]
wantedlb	[Uu][cC][eE][sS]
extralb		[Ee][xX][tT][rR][aA]
yearlb		[Aa][nN][oO]
tipolb		[Tt][iI][pP][oO]

%%


"{"		{ return OPEN; }
"}"		{ return CLOSE; }
"="		{ return EQUAL; }
";"		{ return STOP; }
{medialb}	{ return LABEL_MEDIA; }
{esclb}       	{ return LABEL_CHOICES; }
{normallb}      { return LABEL_NORMAL; }
{prolb}       	{ return LABEL_PRO; }
{extralb}       { return LABEL_EXTRA; }
{yearlb}       	{ return LABEL_YEAR; }
{tipolb}      	{ return LABEL_TIPO; }
{nomelb}	{ return LABEL_NAME; }
{wantedlb}	{ return LABEL_WANTED; }

{virgula}       { yylval.virgula = atof(yytext); return FLOAT; }
{numero}	{ yylval.number = atoi(yytext); return NUMBER; }
{string}        { yylval.string = stripString(yytext); return STRING; }

[" "\n\t]	{ ; }

%%

int yywrap () {
	return 1;
}
